package edu.csu.smartpark.util;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class PhoneCodeUtil {
    @Autowired
    private RedisUtil redisUtil;

    public String sendCode(String phone){
        //TODO 发送验证码并存入redis
        String code = generateCode();
        redisUtil.set(phone, code, 3600);
        return code;
    }

    public String getCode(String phone){
        return (String)redisUtil.get(phone);
    }
    /*
    * @Description: 随机生成六位数验证码
    * @Author: LZY
    * @Date: 2021/4/16 11:26
    * @Params:
    * @Return:
    */
    private String generateCode() {
        return "123456";
    }
}
